const db = require("../config/config");
module.exports = {
  //根据用户id，，获取该用户购物车信息
  AddRoleInfo(req, res) {
    console.log(req.query,'req');
    let roleName=req.query.roleName
    let roleDetail=req.query.roleDetail
    let roleEnable=req.query.roleEnable
    let rolecCreateTime=req.query.rolecCreateTime
    console.log(roleName,roleDetail,roleEnable,rolecCreateTime);
    db.dbMysql(`INSERT INTO roleInfo(roleId,roleName,roleDetail,roleMember,rolecCreateTime,roleEnable) VALUES (?,?,?,?,?,?)`, [null,roleName,roleDetail,0,rolecCreateTime,roleEnable], function (err, data) {
     for(let i=0;i<data.length;i++){
      if(data[i].roleEnable==0){
           data[i].roleEnable=true
      }
      else{
        data[i].roleEnable=false
      }
     }

      if (data) {
        res.send({
          code: 200,
          msg: "角色管理查询成功",
        });
      } else {
        res.send({
          code: 500,
          msg: "服务器错误",
        });
      }
    });
  },
};
